package com.j180.order.sqlProvider;

import java.util.Map;

public class CustomerProvider {

    public String getCustomerByPage(Map<String,String> condition){

        String sql="select \n" +
                "         cus.cid as cusId,\n" +
                "         cus.cname as cusName,\n" +
                "         cus.address as cusAddress,\n" +
                "         _order.oid as oid,\n" +
                "         _order.createTime as createTime,\n" +
                "          top.oid as topId,\n" +
                "          top.num as topNum,\n" +
                "           pro.pid as proPid,\n" +
                "           pro.pname as proName,\n" +
                "           pro.price as proProice     \n" +
                "               from t_customer as cus \n" +
                "               left join t_order  as _order on cus.cid=_order.cid\n" +
                "               left join t_order_product as top on  _order.oid = top.oid\n" +
                "               left join t_product as pro on  top.pid = pro.pid where 1=1";

        if(condition.get("cname")!=null && "".equals(condition.get("cname"))){

            sql+=" and cus.cname like #{cname}";
        }

        return sql;
    }
}
